﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Prabir.wlw.Syntaxhiglighter
{
    public partial class EditForm : Form
    {
        public EditForm(string selectedLangauge, string code)
        {
            InitializeComponent();

            txtCode.Text = code;

            txtCode.SelectionStart = 0;
            txtCode.SelectionLength = 0;

            foreach (string lang in Syntaxhiglighter.Languages)
            {
                int index = cboLanguage.Items.Add(lang);
                if (lang == selectedLangauge)
                    cboLanguage.SelectedIndex = index;
            }

            if (cboLanguage.SelectedItem == null)
                cboLanguage.SelectedIndex = cboLanguage.Items.Add(selectedLangauge);
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        public string Code { get { return txtCode.Text; } }
        public string Langauge { get { return cboLanguage.Text; } }

        public void SelectAll()
        {
            txtCode.SelectionStart = 0;
            txtCode.SelectionLength = txtCode.Text.Length;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

    }
}
